package cn.otrue.patienthealthmanager.http;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

/**
 * 
 * @author G
 * 
 */
public class ServerHandler extends Handler {

	@Override
	public void handleMessage(Message msg) {
		super.handleMessage(msg);
		Bundle data = msg.getData();
		// 得到state
		String state = data.getString(HttpCons.STATE);
		// 判断state的值
		if (state.equals(HttpCons.STATE_ANALYTICAL_ERROR)
				|| state.equals(HttpCons.STATE_EXCEPTION)
				|| state.equals(HttpCons.STATE_FORMAT_ERROR)) {
			onFail(data, state);
		} else {
			String message = data.getString(HttpCons.MESSAGE);
			onSuccess(data, state, message);
		}
	}

	public void onSuccess(Bundle data, String state, String msg) {
	};

	public void onFail(Bundle data, String state) {
	}


}
